﻿<?php include("template/baglanti.php"); include ("template/upload.php"); include("template/header.php"); ?>   
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php
		$ok = ""; 
		$id = intval($_GET['id']);
		$ctID = intval($_GET['ctID']);
		
		$query_list = "SELECT * FROM categori ORDER BY categori_id DESC";
		$sql_list = mysql_query($query_list);
		
		//Categori Listeleme
		$query = ("SELECT * FROM `products` WHERE `PdID` ='$id'");
		$sql = mysql_query($query);
		$row = mysql_fetch_assoc($sql);		
		$save = $_POST['save'];
	
		
		if ($save) {

$Pdsphoto= $row['Pdsphoto'];

//Konu Ekleme Alanı



$categori_id = $_POST['categori_id'];
$Pdname = $_POST['Pdname'];
$Pdnamecn = $_POST['Pdnamecn'];
$Pdinfo = $_POST['Pdinfo'];
$Pdinfocn = $_POST['Pdinfocn'];
$Pdlang = $_POST['Pdlang'];
$Pdshowlist = $_POST['Pdshowlist'];
$Pdshow = $_POST['Pdshow'];
$Pdmodel = $_POST['Pdmodel'];
$Pdunit = $_POST['Pdunit'];
$Pdsize = $_POST['Pdsize'];
$Pdpower = $_POST['Pdpower'];
$Pdarea = $_POST['Pdarea'];
$Pdh = $_POST['Pdh'];



$dosyasmall = $_FILES['dosyasmall'];
if ( $dosyasmall['name'] != '') {
$Pdsphoto = upload_pic($dosyasmall);
}


@mysql_query("update products set
`categori_id` = '$categori_id',
`Pdname` = '$Pdname',
`Pdnamecn` = '$Pdnamecn',
`Pdinfo` = '$Pdinfo',
`Pdinfocn` = '$Pdinfocn',
`Pdsphoto` = '$Pdsphoto',
`Pdlang` = '$Pdlang' ,
`Pdshowlist` = '$Pdshowlist',
`Pdshow` = '$Pdshow',
`Pdmodel` = '$Pdmodel',
`Pdunit` = '$Pdunit',
`Pdsize` = '$Pdsize',
`Pdpower` = '$Pdpower',
`Pdarea` = '$Pdarea',
`Pdh` = '$Pdh'
			WHERE  `PdID` = '$id'
			");

			$ok = "done";
		}
	
		if(!$ok) {




	
		?>

<div class="clear"> </div>
<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
 </div>

<div class="wrapperInside radius flt"> 

<div class="wrapperInsideCapture"> Sub Category Add</div>

<div class="wpForm"> 

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data"  >
	

	
	
			<div class="wpFormLabelBox">
			<div class="wpFormLabel">Category Name </div>
			<div class="wpFormSelecet radius" >
			<select name="categori_id" class="turnintodropdown radius"  >
			
		    <?php 

		            $cns = ("SELECT * FROM `categori` WHERE `categori_id` = '$ctID' ");
					$cn = mysql_query($cns);
					$cnl = mysql_fetch_assoc($cn);	
			?>
				
			<option name="categori_id" value="<?=$cnl['categori_id'];?>"><?=$cnl['categori_name'];?> </option>
			<?php while($row_list = @mysql_fetch_assoc($sql_list)): ?>
			<option name="categori_id" value="<?=$row_list['categori_id'];?>"><?=$row_list['categori_name'];?></option>
		 	<?php endwhile; ?>
			</select>
			</div>
			</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Sub Catorgry Name</div>
	<div class="wpFormText radius"> <input name="Pdname" type="text" value="<?=$row['Pdname'];?>" /></div>
	</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Sub Catorgry (Chinese)Name</div>
	<div class="wpFormText radius"> <input name="Pdnamecn" type="text" value="<?=$row['Pdnamecn'];?>" /></div>
	</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product model (型号)</div>
	<div class="wpFormText radius"> <input name="Pdmodel" type="text" value="<?=$row['Pdmodel'];?>" /></div>
	</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product unit (单位)</div>
	<div class="wpFormText radius"> <input name="Pdunit" type="text" value="<?=$row['Pdunit'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product power (发热量)</div>
	<div class="wpFormText radius"> <input name="Pdpower" type="text" value="<?=$row['Pdpower'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product size (尺寸)</div>
	<div class="wpFormText radius"> <input name="Pdsize" type="text" value="<?=$row['Pdsize'];?>" /></div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product area (使用面积)</div>
	<div class="wpFormText radius"> <input name="Pdarea" type="text" value="<?=$row['Pdarea'];?>" /></div>
	</div>

<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Product height (中心高度)</div>
	<div class="wpFormText radius"> <input name="Pdh" type="text" value="<?=$row['Pdh'];?>" /></div>
	</div>



	<div class="wpFormLabelBox">
	<div class="wpFormLabel "> Sub Category Detail</div>
	<div class="wpFormText" style="display:block; height:100%;">
	<textarea name="Pdinfo" id="textarea" cols="45"rows="5" /  class="mceEditor"> <?=$row['Pdinfo'];?></textarea>
	</div>
	</div>
    
    	<div class="wpFormLabelBox">
	<div class="wpFormLabel "> Sub Category (Chinese)Detail</div>
	<div class="wpFormText" style="display:block; height:100%;">
	<textarea name="Pdinfocn" id="textarea" cols="45"rows="5" /  class="mceEditor"> <?=$row['Pdinfocn'];?></textarea>
	</div>
	</div>




	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Add Photo (250px x 250px)</div>

	<?php if(!empty($row['Pdsphoto'])):?>
	<img src="../upload/products/<?=$row['Pdsphoto'];?>" ><?php else: ?> <img src="../upload/images/noneimg.jpg"> <?php endif; ?><br><br>
	<input type="file" class="nicefileinput wpFormUpload" name="dosyasmall"  />
	</div>




<div class="wpFormLabelBox">
<div class="wpFormLabel">Sub Category Order List </div>
<div class="wpFormSelecet radius" >
<select name="Pdshowlist" class="turnintodropdown radius"  >
<option name="Pdshowlist"> <?=$row['Pdshowlist'];?></option>
<?php for( $i=0; $i<=100; $i++ ) { ?>
<option name ="Pdshowlist"> <?php  echo $i; echo "<br>"; ?> </option> 
<?php } ?>
</select>
</div>
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel"> Language</div>
<div class="wpFormCheck"> 
<input id="radio1" type="radio" name="Pdlang" value="1" <?php if($row['Pdlang'] == 1 ) echo"checked";?> > <label for="radio1"> English </label>
 </div>
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel">Show</div>
<div class="wpFormCheck"> 
<input id="radio1" type="radio" name="Pdshow" value="1" <?php if($row['Pdshow'] == 1 ) echo"checked";?> >  <label> Yes </label>
<input id="radio1" type="radio" name="Pdshow" value="0" style="margin-left:24px;" <?php if($row['Pdshow'] == 0 ) echo"checked";?>>  <label> No</label>
 </div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton">
<input type="submit" name="save"  id="save" value="Save" class="radius">
</div>
</div>


</form>


   
</div>

<?php }	if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Your process well done !<br><a href="productsList.php">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>







<?php include("template/footer.php") ?>

<?php 

function upload_pic($file)
{
	$upload = new upload($file);
	$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
	#big
	$upload->file_new_name_body     = $new_name;
	$upload->process('../upload/products/');
	if($upload->processed){
		$upload->clean();
		return $new_name.'.jpg';
	}
	return 'Hata:'.$upload->error;
}
?>
